﻿<script type="text/javascript">
    $(function () {
        getButton("movehis");
        
        //回车搜索
        $("#ui_movehis_search").find('input').on('keyup', function (event) {
            if (event.keyCode == '13') {
                ui_movehis_searchdata();
            }
        });
    });
    function ui_movehis_init_list(toolbar) {
        $("#ui_movehis_dg").datagrid({       //初始化datagrid
            url: "ashx/bg_movehis.ashx?action=search",
            striped: true, rownumbers: true, pagination: true, pageSize: 20,
            idField: 'id',
            sortName: 'moveDate',
            sortOrder: 'desc',
            pageList: [20, 40, 60, 80, 100],
            frozenColumns: [[
                { field: 'ck', checkbox: true },
                {
                    width: 80,
                    title: '操作人',
                    field: 'userName',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return value.length > 10 ? '<span title="' + value + '">' + value + '</span>' : value;
                    }
                }
            ]],
            columns: [[
                        { field: 'moveDate', title: '迁移时间', sortable: true, width: 120 },
                       { field: 'fromGraveName', title: '原穴位', width: 220 },
                       { field: 'togGaveName', title: '新穴位', width: 220 },
                       { field: 'deadName', title: '死者姓名', width: 80 },
                       { field: 'deadArea', title: '死者区域', width: 100 },
                       {
                           field: 'remark', title: '备注', width: 150, align: 'center',
                           formatter: function (value, row, index) {
                               return value.length > 20 ? '<span title="' + value + '">' + value + '</span>' : value;
                           }
                       },
                       
            ]],
            toolbar: toolbar.length == 0 ? null : toolbar
            //toolbar: [{
            //    text: '导出',
            //    iconCls: 'icon-export',
            //    handler: function () { ui_movehis_export(); }
            //}, {
            //    text: '删除',
            //    iconCls: 'icon-remove',
            //    handler: function () { ui_movehis_delete(); }
            //}]
        });
    }
    function ui_movehis_export() {
        $.show_warning("提示", "导出功能暂未实现");
    }
    function ui_movehis_delete() {
        $.show_warning("提示", "导出功能暂未实现");
        //var rows = $("#ui_movehis_dg").datagrid("getChecked");
        //if (rows.length < 1) {
        //    $.show_warning("提示", "请先勾选要删除的日志");
        //    return;
        //}
        //$.messager.confirm('提示', '确定删除勾选的这' + rows.length + '条日志？', function (r) {
        //    if (r) {
        //        para = {};
        //        para.action = "delete";
        //        para.timespan = new Date().getTime();

        //        var ids = [];
        //        $.each(rows, function (i, row) {
        //            ids.push(row.id);
        //        });
        //        para.ids = ids.join(",");
        //        $.ajax({
        //            url: "ashx/rm_operatelog.ashx",
        //            data: para,
        //            type: "POST",
        //            dataType: "json",
        //            success: function (data) {
        //                if (data.success) {
        //                    $.show_warning("提示", "删除成功！");
        //                    $("#ui_movehis_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
        //                } else {
        //                    $.show_warning("提示", data.msg);
        //                }
        //            }
        //        });
        //    }
        //});
    }
    function ui_movehis_searchdata() {
        var uname = $('#ui_movehis_search').find('[name=ui_movehis_username]').val();
        var paradisecode = $('#ui_movehis_search').find('[name=ui_movehis_paradise_code]').val();
        var toparadisecode = $('#ui_movehis_search').find('[name=ui_movehis_to_paradise_code]').val();
        var stime = $('#ui_movehis_search').find('[name=ui_movehis_datestart]').val();
        var etime = $('#ui_movehis_search').find('[name=ui_movehis_dateend]').val();
        var whereStr = "1=1";
        if (uname != "") {
            whereStr += " and userid in (select id from tbUser where userName like '" + uname + "%')";
        }
        if (paradisecode != "") {
            whereStr += " and fromgraveid in (select id from tbGrave where location LIKE '" + paradisecode + "%')";
        }
        if (toparadisecode != "") {
            whereStr += " and tograveid in (select id from tbGrave where location LIKE '" + toparadisecode + "%')";
        }
        if (stime != "") {
            whereStr += " and movedate>'" + stime + "'";
        }
        if (etime != "") {
            whereStr += " and movedate<'" + etime + "'";
        }

        $("#ui_movehis_dg").datagrid('load', { where: whereStr});
        $("#ui_movehis_dg").datagrid('clearSelections').datagrid('clearChecked');
        //$('#ui_movehis_layout').layout('collapse', 'east');    //隐藏
    }
    function ui_movehis_cleardata() {
        $('#ui_movehis_search input').val('');
        $('#ui_movehis_search select').val('select');
        $('#ui_movehis_datestart').datebox('setValue', '');
        $('#ui_movehis_dateend').datebox('setValue', '');
        $("#ui_movehis_dg").datagrid('load', {});

        $("#ui_movehis_dg").datagrid('clearSelections').datagrid('clearChecked');
        //$('#ui_movehis_layout').layout('collapse', 'east');    //隐藏
    }
</script>
<div id="ui_movehis_layout" class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'east',split:true,border:true,collapsed:true" title="多条件查询"
        style="width: 280px;">
        <div id="ui_movehis_search">
            <table class="tableForm" style="width: 100%; height: 100%; background: #F5F5F5;">
                <tr>
                    <th>迁出骨灰堂：</th>
                    <td>
                        <input type="hidden" value="1=1" name="ui_grave_where" id="ui_grave_where" />
                        <input class="easyui-combotree" id="ui_movehis_paradise_code" name="ui_movehis_paradise_code"
                            data-options="url: 'ashx/bg_paradise.ashx?action=getall', lines:true" />
                    </td>
                </tr>
                <tr>
                    <th>迁入骨灰堂：</th>
                    <td>                        
                        <input class="easyui-combotree" id="ui_movehis_to_paradise_code" name="ui_movehis_to_paradise_code"
                            data-options="url: 'ashx/bg_paradise.ashx?action=getall', lines:true" />
                    </td>
                </tr>
                <tr>
                    <th>
                        操作人：
                    </th>
                    <td>
                        <input name="ui_movehis_username"  class="easyui-textbox"  autocomplete="off" style="width: 130px;" />
                    </td>
                </tr>                
                <tr>
                    <th>
                        迁移时间：
                    </th>
                    <td>
                        <input name="ui_movehis_datestart" id="ui_movehis_datestart"
                            class="easyui-datebox" editable="false" style="width: 140px;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        至：
                    </th>
                    <td>
                        <input name="ui_movehis_dateend" id="ui_movehis_dateend" class="easyui-datebox"
                            editable="false" style="width: 140px;" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
                            onclick="ui_movehis_searchdata();">搜索</a>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-clear" plain="true"
                            onclick="ui_movehis_cleardata();">清空条件</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div data-options="region:'center',border:false">
        <table id="ui_movehis_dg" data-options="fit:true,border:false">
        </table>
    </div>
</div>
